package com.fortune.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fortune.common.paging.PagingData;
import com.fortune.dao.ReturnDepositMgtDao;
import com.fortune.dto.in.returnDepositMgt.ReturnDepositMgtListDto;
import com.fortune.entity.DUserInfo;
import com.fortune.service.ReturnDepositMgtService;
import com.fortune.vo.returnDepositMgt.ReturnDepositMgt;
@Service
public class ReturnDepositMgtServiceImpl implements ReturnDepositMgtService {
	@Autowired 
	private ReturnDepositMgtDao returnDepositMgtDao;
	@Override
	public PagingData<ReturnDepositMgt> page(DUserInfo dUserInfo, ReturnDepositMgtListDto listDto) {
		List<ReturnDepositMgt> list = returnDepositMgtDao.list(dUserInfo, listDto);
		int count = returnDepositMgtDao.listCount(dUserInfo);
		PagingData<ReturnDepositMgt> page = new PagingData<>(list,count);
		return page;
	}
	@Override
	public int allow(DUserInfo dUserInfo, String id, String clientId) {
		String no = returnDepositMgtDao.no(dUserInfo, id, clientId);
		if (no==null) {
			return 2;
		}
		int result = returnDepositMgtDao.allow(dUserInfo, id, clientId);
		return result;
	}
	@Override
	public int assignDriver(DUserInfo dUserInfo, String id, String clientId, String driverId) {
		String no = returnDepositMgtDao.no(dUserInfo, id, clientId);
		if (no==null) {
			return 2;
		}
		int result = returnDepositMgtDao.assignDriver(dUserInfo, id, clientId, driverId);
		return result;
	}

}
